package models;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * Primary key for resource hierarchy relation
 * 
 * @author june
 * 
 */
@Embeddable
public class ResourceHierarchyPK implements Serializable {
	
	@Column(nullable = false)
	private long parentId;
	@Column(nullable = false)
	private long childId;
	
	public long getParentId() {
		return parentId;
	}
	
	public void setParentId(long parentId) {
		this.parentId = parentId;
	}
	
	public long getChildId() {
		return childId;
	}
	
	public void setChildId(long childId) {
		this.childId = childId;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (childId ^ (childId >>> 32));
		result = prime * result + (int) (parentId ^ (parentId >>> 32));
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ResourceHierarchyPK other = (ResourceHierarchyPK) obj;
		if (childId != other.childId)
			return false;
		if (parentId != other.parentId)
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		return "ResourceHierarchyPK [parentId=" + parentId + ", childId=" + childId + "]";
	}
	
}
